import { login, logout, loadImg } from "@/api/login/login.js";
import { setToken, removeToken } from "@/utils/token";
import { Message, MessageBox } from "element-ui";
import router from "@/router";


export function logIn(data, redirect) {
    login(data)
    .then((res) => {
      if (res.code == 2) {
        console.log('账号错误');
      }
      if (res.code == 1) {
        console.log('密码错误');
      }
      if (res.code == 0) {
        // setToken(res.data);
        console.log('等待跳转');
        let url = redirect ||"/";
        router.replace(url);
      } 
    })
    .catch((err) => {});
}